<script language="javascript" type="text/javascript" src="p_ebd/valida_form.js"></script>
<?php 
	$user = $_SESSION['usuario'];
	include "p_usuario/valida_credenciais.php";
	$valCr = new valida_credenciais();
	
	$nivel = array(1,2,4);
	if(!($valCr->validar($nivel))){
		header('Location: index.php?p=denied');
	}
	
	$id = $_GET['i'];
	$resul = mysql_query("SELECT * FROM classes_ebd WHERE classes_ebd.id = $id");
	$classe = mysql_fetch_array($resul);
	
	$resultado = mysql_query("SELECT * FROM membros WHERE membros.id = {$classe['professor_id']}");
	$professor = mysql_fetch_array($resultado);
?>
<div class="form">

	<div class="row">
		<div class="col-md-12">
			<div class="page-header">
				<h2>Registrar Classe da Escola Dominical</h2>
			</div>
		</div>
	</div>
	<div class="row">
	<div class="col-md-3">
			<div class="actions">
				<div class="panel panel-default">
					<div class="panel-heading"><h5>Op&ccedil&otildees</h5></div>
						<div class="panel-body">
							<ul class="nav nav-pills nav-stacked">
								<li><a href="index.php?p=classes" >Classes</a></li>
								<li><a href="index.php?p=ebd">Lista de EBD's</a></li>
							</ul>
						</div><!-- end body -->
				</div><!-- end panel -->
				</div>			
		</div><!-- end col md 3 -->
		<div class="col-md-9">
		<!-- HEAD DE FORMULÃ�RIO -->
		<div class="panel panel-default">
			<div class="panel-heading"><h5>Formul&aacuterio de Registro</h5></div>
			<div class="panel-body">
			<!-- FORMULÃ�RIO -->
			<form  method="post" name="form1" action="p_ebd/editar_c.php">
				<div class="row">
					<div class="col-md-12 form-group"><h6>(<span class="text-danger">*</span>) Campos de preenchimento obrigatório.</h6></div>
				</div>
				<input type="hidden" name="id" value="<?php echo $id;?>">
				
				<div class="row">	
					<div class="form-group col-md-7">
						<label for="classe" >Nome da Classe ou Sala de Aula (<span class="text-danger">*</span>)</label>
    					<input type="text" class="form-control" id="classe" name="classe" value="<?php echo $classe['classe'];?>">
					</div>
					<div class="form-group col-md-5">
						<label for="ebd">Escola Bíblica Dominical (<span class="text-danger">*</span>)</label>
    					<select name="ebd" id="ebd" class="form-control">
		          			<option value="selecione">Selecione...</option>
		          			<?php
									//require "banco/ConexaoBanco.php";
									$query = mysql_query("SELECT ebd.id, ebd.nome_ebd FROM ebd");
									while($lista = mysql_fetch_array($query)) { 
										if($classe['ebd_id'] == $lista['id']){
									?> 
									<option value="<?php echo $lista['id']; ?>" selected><?php echo $lista['nome_ebd']; ?></option>
								<?php }
									else{
										?><option value="<?php echo $lista['id']; ?>" ><?php echo $lista['nome_ebd']; ?></option><?php 
									}}
								?>
		          		</select>
		          	</div>
				</div>
				<div class="row">	
					<div class="form-group col-md-7">
							<label for="professor">Professor (<span class="text-danger">*</span>)</label>
	    					<select name="professor" id="professor" class="form-control">
			          			<option value='selecione'>Selecione...</option>
								<?php
									$query = mysql_query("SELECT id, membro, tipo_membro_id FROM membros WHERE membros.tipo_membro_id = 7");
									while($lista = mysql_fetch_array($query)) { 
										if($lista['id'] == $professor['id']){?> 
											<option value="<?php echo $lista['id']; ?>" selected><?php echo $lista['membro']; ?></option>
										<?php }else{?>
										<option value="<?php echo $lista['id']; ?>"><?php echo $lista['membro']; ?></option>
								<?php }}?>
			          		</select>
					</div>
				</div>
				<div class="row">
					<div class="form-group col-md-12">
						<label for="desc">Descrição da Classe</label>
    					<textarea class="form-control" id="desc" name="desc" rows="4"><?php echo $classe['descricao_classe'];?></textarea>
    					<input type="hidden" name="user" value="<?php echo $user[0];?>">
					</div>
				
				</div>
				<div class="row">
					<div class="form-group col-md-2">
						<input type="submit" value="Salvar" class="btn btn-default " name="enviar" onclick="return valida_classe()" >
					</div>
				</div>
			</form>
			</div>
		</div>

		</div><!-- end col md 12 -->
	</div><!-- end row -->
</div>
			